package org.rsbot.event.impl;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;

import org.rsbot.bot.Bot;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Methods;

public class DrawInventory implements PaintListener {

    private Methods ctx;

    public DrawInventory(Bot bot) {
        ctx = bot.getMethods();
    }

    public void onRepaint(final Graphics render) {
        if (!ctx.isLoggedIn()) {
            return;
        }

        if (ctx.getCurrentTab() != ctx.TAB_INVENTORY) {
            return;
        }

        render.setColor(Color.RED);
        final int[] inventory = ctx.getInventoryArray();
        for (int off = 0; off < inventory.length; off++) {
            if (inventory[off] != -1) {
                final Point location = ctx.getInventoryItemPoint(off);
                render.drawString("[" + inventory[off]+ "]", location.x, location.y);
            }
        }
    }
}
